<template>
  <div class="chat-list" v-for="(item, index) in data" :key="index">
    <div class="photo">
      <img :src="item.avatar" />
    </div>
    <div class="content">
      <div>
        <div class="content_nickname">{{ item.nickname }}</div>
        <div v-if="type === 'add'" class="content_add" @click="addItemId(item)">
          添加
        </div>
        <div v-if="type === 'validate'" class="content_validate">
          <span @click="agree(item)">同意</span>
          <span>拒绝</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "public-list",
  props: {
    data: Array,
    type: String,
  },
  setup(props, { emit }) {
    const addItemId = (item) => emit("getItemId", item);
    const agree = (item) => emit("agree", item);

    return {
      addItemId,
      agree,
    };
  },
};
</script>
